// 定义记分牌
class Scorepanel {
  score = 0
  level = 1
  private scoreEle:HTMLElement
  private levelEle:HTMLElement

  // 最大等级
  maxLevel:number
  // 升级门槛
  upStandard:number
  constructor(maxLevel:number=10, upStandard:number=10){
    this.scoreEle = document.querySelector('#score')!
    this.levelEle = document.querySelector('#level')!
    this.maxLevel = maxLevel
    this.upStandard = upStandard
  }

  // 加分
  addScore():void{
    this.scoreEle.innerText = ++this.score +''
    if(this.score % this.upStandard === 0) {
      this.levelUp()
    }
  }

  // 升级
  levelUp():void{
    if(this.level >= this.maxLevel) return
    this.levelEle.innerText = ++this.level +''
  }
}

export default Scorepanel;